#!/usr/bin/env python
#coding=utf-8
import sys
sys.path.append('/home/jay/xiaojaylib/gae')

import os
os.environ['DJANGO_SETTINGS_MODULE'] = 'gae_manager.settings'
from gae_manager.host.models import Project,App,Account

def usage():
    print 'Usage:list.py projects/apps/accounts'
    sys.exit()

if len(sys.argv) != 2:
    usage()

item = sys.argv[1]
if item == 'projects':
    for p in Project.objects.all():
        print p.name
elif item == 'apps':
    for a in App.objects.all():
        print a.app_id, a.project.name, a.account.email
elif item == 'accounts':
    for a in Account.objects.all():
        print a.email
else:
    usage() 
